Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thank-you for providing this repo, I've been able to use it to test adding zstd compression to the leveled database (which is used as a storage backend for the Riak database). After running some experiments adding this zstd compression library, it has been observed that there appears to be a significant cost from the recent PR which set the
ERL_DIRTY_JOB_CPU_BOUND
on the compress and decompress NIF.See OpenRiak#1. In the leveled perf_SUITE ct test (which is broad database load test), there is a 10%-30% cost from running ZSTD with the flag. Even with a simple unit test there is a clear difference.
With
ERL_DIRTY_JOB_CPU_BOUND
:Compression time ZLIB 1739 LZ4 476 ZSTD 306 Decompression time ZLIB 272 LZ4 88 ZSTD 140
Without
ERL_DIRTY_JOB_CPU_BOUND
:Compression time ZLIB 1877 LZ4 456 ZSTD 251 Decompression time ZLIB 284 LZ4 86 ZSTD 110
Reading the nif guidelines, it talks of the threshold being 1ms before a dirty CPU flag is required. Given the overhead is the flag appropriate for standard compress/decompress function? Perhaps there should be a separate entry point if one is sure the compress/decompress time is within those bounds?
I have limited experience with NIFs, so this PR is provided as a suggestion, but I'm happy to accept that this might not be the right thing to do.